# coding: utf-8
import os,sys
import backConfig

print '读取中... '

svn_cmd1 = 'svn cat %s' % (backConfig.versions[backConfig.source])
# print 'a : ' + svn_cmd1
svn_cmd2 = 'svn cat %s' % (backConfig.versions[backConfig.target])
# print 'b : ' + svn_cmd2

a = os.popen(svn_cmd1).readlines()
b = os.popen(svn_cmd2).readlines()

# print 'aText'
# print a
# print 'bText'
# print b

# print '=' * 80
dica = {}
for i in a:
    if i.strip().lstrip():
        tem = i.split('=')
        dica[tem[0].strip()]=tem[1].strip()
        
changes=[]
adds=[] 
       
for line in b:
    if line.strip().lstrip():
        temp = line.split('=')
        key = temp[0].strip()
        value = temp[1].strip()
        if dica.has_key(key):
            if dica[key] != value:
                changes.append(line)
        else:
            adds.append(line)               

outFile = open(backConfig.out_dir, 'w')
outFile.write('有变化的内容：\n')
for i in changes:
    outFile.write(i)
outFile.write('\n新增的内容:\n')
for i in adds:
    outFile.write(i)
outFile.close()
print 'ok'
